<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="../../lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../ht-css/Project.css"/>
    <!--表单验证-->
	<script type="text/javascript" src="../../lib/Validform/5.3.2/Validform_v5.3.2_min.js?rev=@@hash"></script>
    <!--[if IE 6]>
    <script type="text/javascript" src="../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../ht-css/style-q.css"/>
    <title></title>
</head>
<body>
<form id="addPicForm">
    <div class="cl clearfix pl-20 pt-15">
        <label class="form-label f-l text-r" style="width:90px;"><span class="c-red pr-5">*</span>分类：</label>
        <div class="f-l">
        <div class="size-M radius mb-10">
            <div style="position:relative;z-index: 920;">
                <input type="text" autocomplete="off" class="input-text radius" name="class1" placeholder="请选择一级分类" oninput="goods_listCategory(1)" id="class1" errormsg="格式错误，请重新输入" nullmsg="请填写信息">
                <ul class="relation radius guanlian" id="classUl1">
                </ul>
            </div>
            <span class="Validform_checktip"></span>
        </div>
        <div class="size-M radius mb-10">
            <div style="position:relative;z-index: 910;">
                <input type="text" autocomplete="off" class="input-text radius"  name="class2"  placeholder="请选择二级分类" id="class2" errormsg="格式错误，请重新输入" nullmsg="请填写信息">
                <ul class="relation radius guanlian" id="classUl2">
                </ul>
            </div>
            <span class="Validform_checktip"></span>
        </div>
        <div class="size-M radius mb-10">
            <div style="position: relative;z-index: 900;">
                <input type="text" autocomplete="off" class="input-text radius"  name="class3" placeholder="请选择三级分类" id="class3" errormsg="格式错误，请重新输入" nullmsg="请填写信息">
                <ul class="relation radius guanlian" id="classUl3">
                </ul>
            </div>
            <!-- datatype="/^[a-zA-Z0-9\u4e00-\u9fa5]{1,20}$/"-->
            <span class="Validform_checktip"></span>
        </div>
        </div>
    </div>
    <div class="cl clearfix pl-20 pt-15">
        <label class="form-label f-l text-r" style="width:90px;"><span class="c-red pr-5">*</span>名称：</label>
        <div class="formControls f-l">
        	<input type="text" maxlength="50" class="input-text" value="" placeholder="" id="picName" name="" datatype="/^[a-zA-Z0-9\u4e00-\u9fa5]{1,50}$/" errormsg="格式错误，请重新输入" nullmsg="请填写信息">
        </div>
        <span class="Validform_checktip"></span>
    </div>
    <div class="cl clearfix pl-20 pt-15">
        <label class="form-label f-l text-r" style="width:90px;">图片：</label>
        <div class="formControls f-l">
            <img title="" width="50" height="50" src="" id="myImg" class="mr-10">
            <a style="display: none" onclick="addBtn()">
                <i class="Hui-iconfont f-22 mt-10"></i>
            </a>&nbsp;
            <a style="display: none" onclick="deleteSelect()">删除</a>
            <input id="fileUp" type="file" disabled="disabled" onchange="putDataToPage(event)" style="display: none" errormsg="格式错误，请重新输入" nullmsg="请填写信息">
        </div>
        <!-- datatype="*"-->
        <span class="Validform_checktip"></span>
    </div>
    
    <div class="text-c pd-20">
        <button class="btn btn-primary radius" type="submit">&nbsp;&nbsp;确认&nbsp;&nbsp;</button>
        <button onclick="addCancel();" class="btn radius ml-20" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
    </div>
</form>
</body>
<script type="text/javascript" src="../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../lib/Validform/5.3.2/Validform_v5.3.2_min.js?rev=@@hash"></script>
<script src="../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../ht-js/Project.js?rev=@@hash"></script>
<script>
    yangshi
    function yangshi() {
        console.log("111111111111111")
        $("##layui-layer2").attr("style","margin-left: 42px;")
    }
    var imgInfo = sessionStorage.getItem("imgInfo");
    var imgInfo = JSON.parse(imgInfo)
    var localStorageParameters = decodeURIComponent(web.readCookie("loginData"));
    var JsonObject =JSON.parse(localStorageParameters);
    console.log(imgInfo)
    $("#class1").val(imgInfo.oneCategoryName);
    $("#class2").val(imgInfo.twoCategoryName);
    $("#class3").val(imgInfo.threeCategoryName);
    $("#picName").val(imgInfo.img.img_name);
    $("#myImg").attr("src",imgInfo.img.img_url)
    $("#addPicForm").Validform({
        tiptype:2,
        tipSweep:true,
        callback:function(form){
        	console.log("提交")
			add_submit();
			return false;
        }
    });
    function add_submit() {
        $.ajax({
            contentType: "application/json",
            type: "POST",
            url: root.goodsInter.goods_updateImg,
            cache: false,  //禁用缓存
            dataType: "json",
            data: JSON.stringify({
                "imgId":imgInfo.img.img_id,
                "oneCategoryId":imgInfo.img.one_category_id,
                "twoCategoryId":imgInfo.img.two_category_id,
                "threeCategoryId":imgInfo.img.three_category_id,
                "imgName":$("#picName").val(),
                'imgUrl':imgInfo.img.img_url,
                "lastModifiedBy":JsonObject.user.user_ID
            }),
            success: function (data) {
                if(data.errorCode == 0){
                    window.parent.img_list();
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    showmsg("修改成功！",6);
                }else{
                showmsg(data.errorMessage,5);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest);
            }
        });
    }
    // 提示信息
    function showmsg(msg,icon){
        layer.msg(msg, {
            icon:icon,
            time: 1000
        },function(){
            if(icon==6){
                var index =  parent.location.reload();
                parent.layer.close(index);
            }
        });
    }

    function addCancel() {
        layer.confirm('确定要取消吗？', function(index){
            parent.layer.closeAll();
            layer.close(index);
        });
    }
</script>
</html>